package com.seean.clock.exception;

import com.seean.clock.common.ServerResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 全局异常捕获
 * @authur wsx
 * @date 2019/8/14 10:59
 */
@RestControllerAdvice
public class ExceptionHandle {

    /**
     * ExceptionHandler 捕获什么异常
     * ResponseBody 返回json格式
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    public ServerResponse handle(Exception ex){
        return ServerResponse.error(ex.getMessage());
    }
}